package com.dj.myapp.service;

import android.content.Context;
import android.content.Intent;

import com.dj.myapp.annotation.CombinationUri;
import com.dj.myapp.annotation.InjectParam;
import com.dj.myapp.annotation.RouterParam;
import com.dj.myapp.router.Router;

import java.util.HashMap;

public class RouterService {

    public RouterService() {
        if(null==mRouter){
            mRouter=Router.getInstance();
        }
    }

    private Router mRouter;


    /*...
        @CombinationUri(scheme = "router", host = "com.baronzhang.android.router.SecondActivity")
        @UriParam("preActivity") String preActivity, @IntentExtrasParam("stringParam") String stringParam, @IntentExtrasParam("intParam") int intParam
        routerService.startSecondActivity("MainActivity", "181818", 22222);
        ...*/
    public void startSecondActivity(Context context){
        RouterParam routerParam=new RouterParam();
        HashMap intentExtrasParam=new HashMap();
        intentExtrasParam.put("stringParam","181818");
        intentExtrasParam.put("initParam",22222);
        HashMap uriParam=new HashMap();
        uriParam.put("preActivity","MainActivity");

        CombinationUri uri=new CombinationUri( "router",  "com.router.second",  "",  "");
        routerParam.setUriParam(uriParam)
                .setIntentExtrasParam(intentExtrasParam)
                .setCombinationUri(uri);
        mRouter.creatData(context,routerParam);
    }

    public HashMap<String,Object> getData(Intent intent, InjectParam injectParam){
        return mRouter.injectData(intent,injectParam);
    }




}
